package com.example.roadeyeserver.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.roadeyeserver.constant.ProjectConstant;
import com.example.roadeyeserver.entity.AreaInfo;
import com.example.roadeyeserver.entity.OdCustomDayFlow;
import com.example.roadeyeserver.entity.report.BusTrunkFlowReport;
import com.example.roadeyeserver.entity.report.CityProvinceReport;
import com.example.roadeyeserver.entity.report.RoadRankReport;
import com.example.roadeyeserver.entity.request.CityProvinceStatisticRequest;
import com.example.roadeyeserver.entity.request.CommonRequest;
import com.example.roadeyeserver.entity.vo.OdCustomDayFlowVO;
import com.example.roadeyeserver.entity.vo.StationHourFlowWideVO;
import com.example.roadeyeserver.enums.CarTypeEnum;
import com.example.roadeyeserver.mapper.OdCustomDayFlowMapper;
import com.example.roadeyeserver.result.Result;
import com.example.roadeyeserver.service.AreaInfoService;
import com.example.roadeyeserver.service.OdCustomDayFlowService;
import com.example.roadeyeserver.util.DateTimeUtil;
import com.example.roadeyeserver.util.QueryUtil;
import com.example.roadeyeserver.util.ResultUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.YearMonth;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;

@Service
@Slf4j
public class OdCustomDayFlowServiceImpl extends ServiceImpl<OdCustomDayFlowMapper, OdCustomDayFlow> implements OdCustomDayFlowService {

    @Resource
    private AreaInfoService areaInfoService;

    @Resource
    private OdCustomDayFlowMapper odCustomDayFlowMapper;

    @Override
    public Result<List<BusTrunkFlowReport>> getBusTrunkFlowReport(CityProvinceStatisticRequest request) {
        String isValid = QueryUtil.isValid(request);
        // 判断请求是否合法
        if (!ProjectConstant.TRUE.equals(isValid)) {
            return ResultUtil.fail(isValid);
        }
        String areaType = request.getAreaType();
        if (StringUtils.isEmpty(areaType)) {
            return ResultUtil.fail("请选择查询区域类型!");
        }
        String startEndType = request.getStartEndType();
        if (StringUtils.isEmpty(startEndType)) {
            return ResultUtil.fail("请选择查询开始结束类型!");
        }
        // 区域代码集合
        List<AreaInfo> areaCodes = areaInfoService.list();
        // areaCode-AreaInfo映射
        Map<String, AreaInfo> areaCodeMap = areaCodes.stream()
                .collect(Collectors.toMap(AreaInfo::getAreaCode, area -> area));
        // 浙江省内宁波市外的区域代码集合
        List<AreaInfo> zheJiangAreas = areaCodes.stream()
                .filter(area ->
                        area.getAreaCode().startsWith(ProjectConstant.ZHE_JIANG_CODE_START) &&
                        !area.getAreaCode().startsWith(ProjectConstant.NING_BO_AREA_CODE_START))
                .collect(Collectors.toList());
        List<String> zheJiangAreaCodes = zheJiangAreas.stream()
                .map(AreaInfo::getAreaCode)
                .collect(Collectors.toList());
        // 浙江省外的区域代码集合
        List<AreaInfo> otherAreas = areaCodes.stream()
                .filter(area -> !area.getAreaCode().startsWith(ProjectConstant.ZHE_JIANG_CODE_START))
                .collect(Collectors.toList());
        List<String> otherAreaCodes = otherAreas.stream()
                .map(AreaInfo::getAreaCode)
                .collect(Collectors.toList());
        // 开始时间
        String startTime = request.getStartTime();
        // 开始时间所在月份的天数
        YearMonth yearMonth = YearMonth.parse(startTime.substring(0, 7),
                DateTimeFormatter.ofPattern("yyyy-MM"));
        int days = yearMonth.lengthOfMonth();
        // 按要求查询数据
        List<OdCustomDayFlowVO> list = new ArrayList<>();
        if (ProjectConstant.ONE_STRING.equals(startEndType)) {
            // 起点宁波市
            request.setStartId(ProjectConstant.NING_BO_CODE);
            if (ProjectConstant.ONE_STRING.equals(areaType)) {
                // 市外省内
                request.setEndAreaIds(zheJiangAreaCodes);
            } else if (ProjectConstant.TWO_STRING.equals(areaType)) {
                // 市到省外
                request.setEndAreaIds(otherAreaCodes);
            }
            list = odCustomDayFlowMapper.getBusTrunkFlowStartReport(request);
        } else if (ProjectConstant.TWO_STRING.equals(startEndType)) {
            // 终点宁波市
            request.setEndId(ProjectConstant.NING_BO_CODE);
            if (ProjectConstant.ONE_STRING.equals(areaType)) {
                // 市外省内
                request.setStartAreaIds(zheJiangAreaCodes);
            } else if (ProjectConstant.TWO_STRING.equals(areaType)) {
                // 市到省外
                request.setStartAreaIds(otherAreaCodes);
            }
            list = odCustomDayFlowMapper.getBusTrunkFlowEndReport(request);
        }
        List<BusTrunkFlowReport> result = new ArrayList<>();
        list.forEach(item -> {
            BusTrunkFlowReport report = new BusTrunkFlowReport();
            report.setStartCode(item.getCustomIdStart());
            // 起点信息
            AreaInfo startAreaInfo = areaCodeMap.get(item.getCustomIdStart());
            if (startAreaInfo != null) {
                // 起点名称
                String startName = startAreaInfo.getAreaName();
                report.setStartName(startName);
                // 起点经度
                String startLon = startAreaInfo.getLon();
                report.setStartLon(startLon);
                // 起点纬度
                String startLat = startAreaInfo.getLat();
                report.setStartLat(startLat);
            }
            report.setEndCode(item.getCustomIdEnd());
            // 终点信息
            AreaInfo endAreaInfo = areaCodeMap.get(item.getCustomIdEnd());
            if (endAreaInfo != null) {
                // 终点名称
                String endName = endAreaInfo.getAreaName();
                report.setEndName(endName);
                // 终点经度
                String endLon = endAreaInfo.getLon();
                report.setEndLon(endLon);
                // 终点纬度
                String endLat = endAreaInfo.getLat();
                report.setEndLat(endLat);
            }
            report.setVhc1(item.getVhc1());
            report.setVhc2(item.getVhc2());
            report.setVhc3(item.getVhc3());
            report.setVhc4(item.getVhc4());
            report.setVhc11(item.getVhc11());
            report.setVhc12(item.getVhc12());
            report.setVhc13(item.getVhc13());
            report.setVhc14(item.getVhc14());
            report.setVhc15(item.getVhc15());
            report.setVhc16(item.getVhc16());
            report.setVhc21(item.getVhc21());
            report.setVhc22(item.getVhc22());
            report.setVhc23(item.getVhc23());
            report.setVhc24(item.getVhc24());
            report.setVhc25(item.getVhc25());
            report.setVhc26(item.getVhc26());
            int totalFlow = item.getVhc1() + item.getVhc2() + item.getVhc3() + item.getVhc4() +
                    item.getVhc11() + item.getVhc12() + item.getVhc13() + item.getVhc14() + item.getVhc15() + item.getVhc16();
            report.setTotalFlow(totalFlow);
            // 计算日均流量(没有车型选择下的日均流量计算)
            report.setAvgFlow(totalFlow / days);
            result.add(report);
        });
        // 车型选择
        String carTypeChoose = request.getCarTypeChoose();
        // 如果对车型没有选择,直接返回
        if (StringUtils.isEmpty(carTypeChoose)) {
            return ResultUtil.success(result);
        }
        CarTypeEnum.calculateAndSetListFlow(carTypeChoose, result);
        // 计算日均流量(有车型选择的情况下计算日均流量)
        result.forEach(item -> item.setAvgFlow(item.getTotalFlow() / days));
        return ResultUtil.success(result);
    }

    @Override
    public Result<List<CityProvinceReport>> getCityProvinceReport(CityProvinceStatisticRequest request) {
        String isValid = QueryUtil.isValid(request);
        // 判断请求是否合法
        if (!ProjectConstant.TRUE.equals(isValid)) {
            return ResultUtil.fail(isValid);
        }
        String areaType = request.getAreaType();
        if (StringUtils.isEmpty(areaType)) {
            return ResultUtil.fail("请选择查询区域类型!");
        }
        String startEndType = request.getStartEndType();
        if (StringUtils.isEmpty(startEndType)) {
            return ResultUtil.fail("请选择查询开始结束类型!");
        }
        // 区域代码集合
        List<AreaInfo> areaCodes = areaInfoService.list();
        // 浙江省内宁波市外的区域代码集合
        List<AreaInfo> zheJiangAreas = areaCodes.stream()
                .filter(area -> area.getAreaCode().startsWith(ProjectConstant.ZHE_JIANG_CODE_START) &&
                        !area.getAreaCode().startsWith(ProjectConstant.NING_BO_AREA_CODE_START))
                .collect(Collectors.toList());
        List<String> zheJiangAreaCodes = zheJiangAreas.stream()
                .map(AreaInfo::getAreaCode)
                .collect(Collectors.toList());
        // 浙江省外的区域代码集合
        List<AreaInfo> otherAreas = areaCodes.stream()
                .filter(area -> !area.getAreaCode().startsWith(ProjectConstant.ZHE_JIANG_CODE_START))
                .collect(Collectors.toList());
        List<String> otherAreaCodes = otherAreas.stream()
                .map(AreaInfo::getAreaCode)
                .collect(Collectors.toList());
        // 按要求查询数据
        List<OdCustomDayFlowVO> list = new ArrayList<>();
        if (ProjectConstant.ONE_STRING.equals(startEndType)) {
            // 起点宁波市
            request.setStartId(ProjectConstant.NING_BO_CODE);
            if (ProjectConstant.ONE_STRING.equals(areaType)) {
                // 市外省内
                request.setEndAreaIds(zheJiangAreaCodes);
            } else if (ProjectConstant.TWO_STRING.equals(areaType)) {
                // 市到省外
                request.setEndAreaIds(otherAreaCodes);
            }
            list = odCustomDayFlowMapper.getBusTrunkFlowStartRecord(request);
        } else if (ProjectConstant.TWO_STRING.equals(startEndType)) {
            // 终点宁波市
            request.setEndId(ProjectConstant.NING_BO_CODE);
            if (ProjectConstant.ONE_STRING.equals(areaType)) {
                // 市外省内
                request.setStartAreaIds(zheJiangAreaCodes);
            } else if (ProjectConstant.TWO_STRING.equals(areaType)) {
                // 市到省外
                request.setStartAreaIds(otherAreaCodes);
            }
            list = odCustomDayFlowMapper.getBusTrunkFlowEndRecord(request);
        }
        // 根据时间类型区分,填写所属时间点并在这个时间点内做累加
        String timeType = request.getTimeType();
        // 根据开始时间、结束时间、时间类型生成时间点列表
        List<String> timePointList = DateTimeUtil.generateTimeList(request.getStartTime(), request.getEndTime(), timeType);
        // 返回列表
        List<CityProvinceReport> result = new ArrayList<>();
        // 遍历时间点列表并获取对应的数据
        for (int i = 0; i < timePointList.size() - 1; i++) {
            CityProvinceReport report = new CityProvinceReport();
            // 当前时间点
            String timePoint = timePointList.get(i);
            Date timePointDate = DateUtil.parse(timePoint);
            // 下一个时间点
            String nextTimePoint = timePointList.get(i + 1);
            Date nextTimePointDate = DateUtil.parse(nextTimePoint);
            // 时间点
            String timePointDisplay = DateTimeUtil.getTimePoint(timePoint, timeType);
            report.setTimePoint(timePointDisplay);
            // 这个时间段内的OD流量
            int busFlow = 0;
            int truckFlow = 0;
            if (CollectionUtil.isNotEmpty(list)) {
                List<OdCustomDayFlowVO> records = list.stream()
                        .filter(item -> item.getTime() != null && item.getTime().compareTo(timePointDate) >= 0 && item.getTime().compareTo(nextTimePointDate) < 0)
                        .collect(Collectors.toList());
                busFlow = records.stream()
                        .mapToInt(item -> item.getVhc1() + item.getVhc2() + item.getVhc3() + item.getVhc4())
                        .sum();
                truckFlow = records.stream()
                        .mapToInt(item -> item.getVhc11() + item.getVhc12() + item.getVhc13() + item.getVhc14() + item.getVhc15() + item.getVhc16())
                        .sum();
                report.setVhc1(records.stream().mapToInt(OdCustomDayFlowVO::getVhc1).sum());
                report.setVhc2(records.stream().mapToInt(OdCustomDayFlowVO::getVhc2).sum());
                report.setVhc3(records.stream().mapToInt(OdCustomDayFlowVO::getVhc3).sum());
                report.setVhc4(records.stream().mapToInt(OdCustomDayFlowVO::getVhc4).sum());
                report.setVhc11(records.stream().mapToInt(OdCustomDayFlowVO::getVhc11).sum());
                report.setVhc12(records.stream().mapToInt(OdCustomDayFlowVO::getVhc12).sum());
                report.setVhc13(records.stream().mapToInt(OdCustomDayFlowVO::getVhc13).sum());
                report.setVhc14(records.stream().mapToInt(OdCustomDayFlowVO::getVhc14).sum());
                report.setVhc15(records.stream().mapToInt(OdCustomDayFlowVO::getVhc15).sum());
                report.setVhc16(records.stream().mapToInt(OdCustomDayFlowVO::getVhc16).sum());
                report.setVhc21(records.stream().mapToInt(OdCustomDayFlowVO::getVhc21).sum());
                report.setVhc22(records.stream().mapToInt(OdCustomDayFlowVO::getVhc22).sum());
                report.setVhc23(records.stream().mapToInt(OdCustomDayFlowVO::getVhc23).sum());
                report.setVhc24(records.stream().mapToInt(OdCustomDayFlowVO::getVhc24).sum());
                report.setVhc25(records.stream().mapToInt(OdCustomDayFlowVO::getVhc25).sum());
                report.setVhc26(records.stream().mapToInt(OdCustomDayFlowVO::getVhc26).sum());
            }
            report.setBusFlow(busFlow);
            report.setTruckFlow(truckFlow);
            result.add(report);
        }
        // 车型选择
        String carTypeChoose = request.getCarTypeChoose();
        // 如果对车型没有选择,直接返回
        if (StringUtils.isEmpty(carTypeChoose)) {
            return ResultUtil.success(result);
        }
        CarTypeEnum.calculateAndSetListFlow(carTypeChoose, result);
        return ResultUtil.success(result);
    }

    @Override
    public Result<List<BusTrunkFlowReport>> getBusTrunkFlowRank(CityProvinceStatisticRequest request) {
        String isValid = QueryUtil.isValid(request);
        // 判断请求是否合法
        if (!ProjectConstant.TRUE.equals(isValid)) {
            return ResultUtil.fail(isValid);
        }
        String areaType = request.getAreaType();
        if (StringUtils.isEmpty(areaType)) {
            return ResultUtil.fail("请选择查询区域类型!");
        }
        String startEndType = request.getStartEndType();
        if (StringUtils.isEmpty(startEndType)) {
            return ResultUtil.fail("请选择查询开始结束类型!");
        }
        // 区域代码集合
        List<AreaInfo> areaCodes = areaInfoService.list();
        // areaCode-AreaInfo映射
        Map<String, AreaInfo> areaCodeMap = areaCodes.stream()
                .collect(Collectors.toMap(AreaInfo::getAreaCode, area -> area));
        // 浙江省内宁波市外的区域代码集合
        List<AreaInfo> zheJiangAreas = areaCodes.stream()
                .filter(area -> area.getAreaCode().startsWith(ProjectConstant.ZHE_JIANG_CODE_START) &&
                        !area.getAreaCode().startsWith(ProjectConstant.NING_BO_AREA_CODE_START))
                .collect(Collectors.toList());
        List<String> zheJiangAreaCodes = zheJiangAreas.stream()
                .map(AreaInfo::getAreaCode)
                .collect(Collectors.toList());
        // 浙江省外的区域代码集合
        List<AreaInfo> otherAreas = areaCodes.stream()
                .filter(area -> !area.getAreaCode().startsWith(ProjectConstant.ZHE_JIANG_CODE_START))
                .collect(Collectors.toList());
        List<String> otherAreaCodes = otherAreas.stream()
                .map(AreaInfo::getAreaCode)
                .collect(Collectors.toList());
        // 按要求查询数据
        List<OdCustomDayFlowVO> list = new ArrayList<>();
        if (ProjectConstant.ONE_STRING.equals(startEndType)) {
            // 起点宁波市
            request.setStartId(ProjectConstant.NING_BO_CODE);
            if (ProjectConstant.ONE_STRING.equals(areaType)) {
                // 市外省内
                request.setEndAreaIds(zheJiangAreaCodes);
            } else if (ProjectConstant.TWO_STRING.equals(areaType)) {
                // 市到省外
                request.setEndAreaIds(otherAreaCodes);
            }
            list = odCustomDayFlowMapper.getBusTrunkFlowStartReport(request);
        } else if (ProjectConstant.TWO_STRING.equals(startEndType)) {
            // 终点宁波市
            request.setEndId(ProjectConstant.NING_BO_CODE);
            if (ProjectConstant.ONE_STRING.equals(areaType)) {
                // 市外省内
                request.setStartAreaIds(zheJiangAreaCodes);
            } else if (ProjectConstant.TWO_STRING.equals(areaType)) {
                // 市到省外
                request.setStartAreaIds(otherAreaCodes);
            }
            list = odCustomDayFlowMapper.getBusTrunkFlowEndReport(request);
        }
        List<BusTrunkFlowReport> result = new ArrayList<>();
        list.forEach(item -> {
            BusTrunkFlowReport report = new BusTrunkFlowReport();
            report.setStartCode(item.getCustomIdStart());
            report.setStartName(areaCodeMap.get(item.getCustomIdStart()).getAreaName());
            report.setEndCode(item.getCustomIdEnd());
            report.setEndName(areaCodeMap.get(item.getCustomIdEnd()).getAreaName());
            report.setVhc1(item.getVhc1());
            report.setVhc2(item.getVhc2());
            report.setVhc3(item.getVhc3());
            report.setVhc4(item.getVhc4());
            report.setVhc11(item.getVhc11());
            report.setVhc12(item.getVhc12());
            report.setVhc13(item.getVhc13());
            report.setVhc14(item.getVhc14());
            report.setVhc15(item.getVhc15());
            report.setVhc16(item.getVhc16());
            report.setVhc21(item.getVhc21());
            report.setVhc22(item.getVhc22());
            report.setVhc23(item.getVhc23());
            report.setVhc24(item.getVhc24());
            report.setVhc25(item.getVhc25());
            report.setVhc26(item.getVhc26());
            // 客车流量
            Integer busFlow = item.getVhc1() + item.getVhc2() + item.getVhc3() + item.getVhc4();
            // 货车流量
            Integer truckFlow = item.getVhc11() + item.getVhc12() + item.getVhc13() + item.getVhc14() + item.getVhc15() + item.getVhc16();
            report.setBusFlow(busFlow);
            report.setTruckFlow(truckFlow);
            // 总流量
            report.setTotalFlow(busFlow + truckFlow);
            result.add(report);
        });
        // 根据总流量从高到低排序
        result.sort(Comparator.comparingInt(BusTrunkFlowReport::getTotalFlow).reversed());
        // 车型选择
        String carTypeChoose = request.getCarTypeChoose();
        // 如果对车型没有选择,直接返回
        if (StringUtils.isEmpty(carTypeChoose)) {
            return ResultUtil.success(result);
        }
        CarTypeEnum.calculateAndSetListFlow(carTypeChoose, result);
        return ResultUtil.success(result);
    }

    @Override
    public Result<List<BusTrunkFlowReport>> getCountyReport(CityProvinceStatisticRequest request) {
        String isValid = QueryUtil.isValid(request);
        // 判断请求是否合法
        if (!ProjectConstant.TRUE.equals(isValid)) {
            return ResultUtil.fail(isValid);
        }
        // 区域代码集合
        List<AreaInfo> areaCodes = areaInfoService.list();
        // areaCode-AreaInfo映射
        Map<String, AreaInfo> areaCodeMap = areaCodes.stream()
                .collect(Collectors.toMap(AreaInfo::getAreaCode, area -> area));
        // 宁波市内的区域代码集合
        List<AreaInfo> ningBoAreas = areaCodes.stream()
                .filter(area -> area.getAreaCode().startsWith(ProjectConstant.NING_BO_AREA_CODE_START))
                .collect(Collectors.toList());
        List<String> ningBoAreaCodes = ningBoAreas.stream()
                .map(AreaInfo::getAreaCode)
                .collect(Collectors.toList());
        request.setStartAreaIds(ningBoAreaCodes);
        request.setEndAreaIds(ningBoAreaCodes);
        // 根据时间类型区分,填写所属时间点并在这个时间点内做累加
        String timeType = request.getTimeType();
        // 根据开始时间、结束时间、时间类型生成时间点列表
        List<String> timePointList = DateTimeUtil.generateTimeList(request.getStartTime(), request.getEndTime(), timeType);
        // 按要求查询数据
        List<OdCustomDayFlowVO> list = odCustomDayFlowMapper.getCityFlowRecords(request);
        List<BusTrunkFlowReport> result = new ArrayList<>();
        // 遍历时间点列表并获取对应的数据
        for (int i = 0; i < timePointList.size() - 1; i++) {
            BusTrunkFlowReport report = new BusTrunkFlowReport();
            // 当前时间点
            String timePoint = timePointList.get(i);
            Date timePointDate = DateUtil.parse(timePoint);
            // 下一个时间点
            String nextTimePoint = timePointList.get(i + 1);
            Date nextTimePointDate = DateUtil.parse(nextTimePoint);
            // 时间点
            String timePointDisplay = DateTimeUtil.getTimePoint(timePoint, timeType);
            report.setTimePoint(timePointDisplay);
            // 这个时间段内的OD流量
            int busFlow = 0;
            int truckFlow = 0;
            if (CollectionUtil.isNotEmpty(list)) {
                List<OdCustomDayFlowVO> flowList = list.stream()
                        .filter(item -> item.getTime() != null &&  item.getTime().compareTo(timePointDate) >= 0 && item.getTime().compareTo(nextTimePointDate) < 0)
                        .collect(Collectors.toList());
                busFlow = flowList.stream()
                        .mapToInt(item -> item.getVhc1() + item.getVhc2() + item.getVhc3() + item.getVhc4())
                        .sum();
                truckFlow = flowList.stream()
                        .mapToInt(item -> item.getVhc11() + item.getVhc12() + item.getVhc13() + item.getVhc14() + item.getVhc15() + item.getVhc16())
                        .sum();
                report.setVhc1(flowList.stream().mapToInt(OdCustomDayFlowVO::getVhc1).sum());
                report.setVhc2(flowList.stream().mapToInt(OdCustomDayFlowVO::getVhc2).sum());
                report.setVhc3(flowList.stream().mapToInt(OdCustomDayFlowVO::getVhc3).sum());
                report.setVhc4(flowList.stream().mapToInt(OdCustomDayFlowVO::getVhc4).sum());
                report.setVhc11(flowList.stream().mapToInt(OdCustomDayFlowVO::getVhc11).sum());
                report.setVhc12(flowList.stream().mapToInt(OdCustomDayFlowVO::getVhc12).sum());
                report.setVhc13(flowList.stream().mapToInt(OdCustomDayFlowVO::getVhc13).sum());
                report.setVhc14(flowList.stream().mapToInt(OdCustomDayFlowVO::getVhc14).sum());
                report.setVhc15(flowList.stream().mapToInt(OdCustomDayFlowVO::getVhc15).sum());
                report.setVhc16(flowList.stream().mapToInt(OdCustomDayFlowVO::getVhc16).sum());
                report.setVhc21(flowList.stream().mapToInt(OdCustomDayFlowVO::getVhc21).sum());
                report.setVhc22(flowList.stream().mapToInt(OdCustomDayFlowVO::getVhc22).sum());
                report.setVhc23(flowList.stream().mapToInt(OdCustomDayFlowVO::getVhc23).sum());
                report.setVhc24(flowList.stream().mapToInt(OdCustomDayFlowVO::getVhc24).sum());
                report.setVhc25(flowList.stream().mapToInt(OdCustomDayFlowVO::getVhc25).sum());
                report.setVhc26(flowList.stream().mapToInt(OdCustomDayFlowVO::getVhc26).sum());
            }
            report.setBusFlow(busFlow);
            report.setTruckFlow(truckFlow);
            // 总流量
            int totalFlow = busFlow + truckFlow;
            report.setTotalFlow(totalFlow);
            result.add(report);
        }
        // 车型选择
        String carTypeChoose = request.getCarTypeChoose();
        // 如果对车型没有选择,直接返回
        if (StringUtils.isEmpty(carTypeChoose)) {
            return ResultUtil.success(result);
        }
        CarTypeEnum.calculateAndSetListFlow(carTypeChoose, result);
        return ResultUtil.success(result);
    }
}
